package com.imessage.type;


import com.fasterxml.jackson.annotation.JsonValue;
import io.ebean.annotation.DbEnumValue;

import java.util.Objects;

public enum BusinessAppleState implements EnumMessage{


	available("1", "可使用","available",""),
	used("2", "已使用","used",""),
	error("3", "错误数据","error","");

	String code;
	String display;
	String name;
	String value;

	private BusinessAppleState(String code, String display, String name, String value) {
		this.code = code;
		this.display = display;
		this.name=name;
		this.value=value;
	}

	//获取枚举实例
	public static BusinessAppleState fromValue(String code) {
		for (BusinessAppleState statusEnum : BusinessAppleState.values()) {
			if (Objects.equals(code, statusEnum.getCode())) {
				return statusEnum;
			}
		}
		return BusinessAppleState.available;
	}

	//获取枚举实例
	public static BusinessAppleState toValue(String display) {
		for (BusinessAppleState statusEnum : BusinessAppleState.values()) {
			if (Objects.equals(display, statusEnum.getDisplay())) {
				return statusEnum;
			}
		}
		return BusinessAppleState.available;
	}


	@DbEnumValue
	@Override
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	@JsonValue
	public String getDisplay() {
		return display;
	}

	public void setDisplay(String display) {
		this.display = display;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	
	@Override
	public String toString() {		
		return display;
	}
}
